﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace MyCourseManager.Common
{
    public class CommondBase : ICommand
    {
        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object parameter)
        {
            return cando?.Invoke(parameter) == true;
        }

        public void Execute(object parameter)
        {
            dosomthing?.Invoke(parameter);
        }

        /// <summary>
        /// 判断是否能执行命令
        /// </summary>
        public Func<object,bool> cando { get; set; }
        
        /// <summary>
        /// 执行委托所挂载的方法
        /// </summary>
        public Action<object> dosomthing { get; set; }


        public void RaiseExcute()
        {
            CanExecuteChanged?.Invoke(this,new EventArgs());
        }
    }
}
